#!/bin/bash

set -e

FPGA_BDF="0000:04:00.0"
LOG_TAG="platform_reboot"
REBOOT_REG_OFFSET=0x4
REBOOT_ENABLE=0xdeadbeef

logger -t $LOG_TAG "Writing to power cycle control register to initiate reboot"
fpga write32 "$FPGA_BDF" "$REBOOT_REG_OFFSET" "$REBOOT_ENABLE"
if [ $? -ne 0 ]; then
    logger -t $LOG_TAG -p error "Error writing to power cycle control register on fpga $FPGA_BDF"
fi